<template>
  <div id="container">
    <img class="bgImg" src="@/assets/images/checkBg2.jpg" alt="">
    <div class="content">
      <p>请输入口令</p>
      <el-input maxlength="20" v-model="startCommand" class="inputClass"></el-input>
      <el-button class="submitBtn" :disabled="submitDisabled" type="primary" @click="submit"> 确定</el-button>
      <!-- <a class="download-link" @click="submit" id="apple-link" href="#">确定</a> -->
    </div>
  </div>
  <div class="bottom">
    <div>
      <a href="https://beian.miit.gov.cn" target="_blank">粤ICP备2024161278号</a>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, watch } from 'vue'
import { getConfig, saveConfig } from '@/api/check/index'
import { useRouter } from 'vue-router';

const router = useRouter()
const startCommand = ref('')
const submitDisabled = ref(true)

watch(startCommand, (now) => {
  if(now) {
    submitDisabled.value = false;
  }else{
    submitDisabled.value = true;
  }
})

onMounted(() => {
  // saveConfig({
  //   key:'startCommand',
  //   value:'增员晋升666'
  // })
})

const submit = () => {
  getConfigFn()
}

const getConfigFn = async () => {
  try {
    // const res = await getConfig({
    //   key: 'startCommand'
    // })
    if (startCommand.value === '增员晋升666') {
      router.push('/dVersion')
    } else {
      const routeData = router.resolve('/commandError');
      window.open(routeData.href, '_blank');
      console.log('口令错误')
    }
  } catch (error) {

  }
}
</script>

<style scoped>
.submitBtn {
  width: 246px;
  margin: 20px 0;
}

.download-link {
  display: block;
  margin: 20px 0;
  padding: 6px 20px;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
  background-color: #4285f4;
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
}

.content {
  width: 250px;
  background-color: #fff;
  border-radius: 10px;
  padding: 3rem 5rem 4rem 5rem;
  box-sizing: content-box;
  position: absolute;
  z-index: 2;
}

.download-link:hover {
  background-color: #3c79de;
}

.bottom {
  position: fixed;
  bottom: 20px;
  padding: 10px;
  font-size: 14px;
  width: 100%;
  left: 0;
  z-index: 2;
}

#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  justify-content: center;
}

.el-input.inputClass {
  width: 245px;
}

.bgImg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  object-fit: cover;
  width: 100vw;
  height: 100vh;
  opacity: 0.65;
}
</style>
